/*
 * Copyright (c)$today.year.month.day
 *  admin:郑程荣.
 *  文件名:ProjectListActivity2.java
 *  项目功能:
 *//*


*/
/*
 * Copyright (c)$today.year.month.day
 *  admin:郑程荣.
 *  文件名:ProjectListActivity.java
 *  项目功能:
 *//*


package com.jg.myproject.module.projectinfo;

import android.content.Intent;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jg.myproject.api.Const;
import com.jg.myproject.api.bean.CommonRequestBean;
import com.jg.myproject.api.bean.reponse.CommonReponseBean;
import com.jg.myproject.module.base.BaseActivity;
import com.jg.myproject.module.home.HomeActivity;
import com.jg.myproject.presenter.ProjectListPresenter;
import com.jg.myproject.pview.IProjectListView;
import com.zcr.myproject.R;

import java.util.ArrayList;

import butterknife.BindView;

*/
/**
 * Created by llz on 2018/11/19.
 *//*

public class ProjectListActivity2 extends BaseActivity implements IProjectListView {


    ProjectListPresenter mProjectListPresenter;

    @BindView(R.id.rv_content)
    RecyclerView mRvContent;
    @BindView(R.id.swipeRefreshLayout)
    SwipeRefreshLayout mSwipeRefreshLayout;
    private ArrayList<CommonReponseBean> mBeans;
    public BaseQuickAdapter mBaseQuickAdapter;
    private int mNextRequestPage = 1;

    @Override
    protected int attachLayoutRes() {
        return R.layout.activity_project_list;
    }
    @Override
    protected void initViews() {
        initTitle(false, "工程列表");
        mProjectListPresenter = new ProjectListPresenter(this);

    }
    @Override
    protected void updateViews(boolean isRefresh) {
        mSwipeRefreshLayout.setColorSchemeResources(R.color.main_color);
        mRvContent.setLayoutManager(new LinearLayoutManager(this));
        mBeans = new ArrayList<CommonReponseBean>();
        CommonReponseBean commonReponseBean = new CommonReponseBean();
        hideLoading();
        commonReponseBean.setGcName("碧桂园优惠大甩卖");
        commonReponseBean.setDisplayName("原价要888，现在只要88");
        mBeans.add(commonReponseBean);
        mBaseQuickAdapter = new BaseQuickAdapter<CommonReponseBean, BaseViewHolder>(R.layout.item_project_list, mBeans) {
            @Override
            protected void convert(BaseViewHolder baseViewHolder, CommonReponseBean bean) {
                TextView tv_01 = baseViewHolder.getView(R.id.tv_01);
                TextView tv_02 = baseViewHolder.getView(R.id.tv_02);
                TextView tv_03 = baseViewHolder.getView(R.id.tv_03);
                tv_01.setText(baseViewHolder.getAdapterPosition() + 1 + "");
                tv_02.setText(bean.getGcName());
                tv_03.setText(bean.getMonitorPartName());
            }
        };
        mBaseQuickAdapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {
            @Override
            public void onLoadMoreRequested() {
                boolean isRefresh = mNextRequestPage == 1;
                mNextRequestPage++;
                CommonRequestBean commonRequestBean = new CommonRequestBean();
                commonRequestBean.setPageNo(mNextRequestPage);
                commonRequestBean.setPageSize(Const.PAGE_SIZE);
                mProjectListPresenter.getData(isRefresh,commonRequestBean,mBeans,mBaseQuickAdapter,mSwipeRefreshLayout);
            }
        }, mRvContent);
        initRefreshLayout(); // 下拉刷新
        mRvContent.setAdapter(mBaseQuickAdapter);
        mBaseQuickAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                Intent intent = new Intent(ProjectListActivity2.this, HomeActivity.class);
                startActivity(intent);
            }
        });
    }
    private void initRefreshLayout() {
        mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                mNextRequestPage = 1;
                mBaseQuickAdapter.setEnableLoadMore(false);//这里的作用是防止下拉刷新的时候还可以上拉加载
                CommonRequestBean commonRequestBean = new CommonRequestBean();
                commonRequestBean.setPageNo(mNextRequestPage);
                commonRequestBean.setPageSize(Const.PAGE_SIZE);
                mProjectListPresenter.getData(true,commonRequestBean,mBeans,mBaseQuickAdapter,mSwipeRefreshLayout);
            }
        });
    }






}
*/
